package com.htx.oldbookpavilion.common;

import java.util.List;

/**
 * 标准分页数据类
 * @param <T>
 */
public class StandardPageData<T> {

    /**
     * 当前页
     */
    private int currentPage;

    /**
     * 每页条数
     */
    private int pageSize;

    /**
     * 总条数
     */
    private long total;

    /**
     * 查询开始下标
     */
    private int startIndex;

    /**
     * 查询参数
     */
    private T searchParam;

    /**
     * 分页数据
     */
    private List<T> records;

    public StandardPageData() {
    }

    public int getCurrentPage() {
        return currentPage;
    }

    public void setCurrentPage(int currentPage) {
        this.currentPage = currentPage;
    }

    public int getPageSize() {
        return pageSize;
    }

    public void setPageSize(int pageSize) {
        this.pageSize = pageSize;
    }

    public long getTotal() {
        return total;
    }

    public void setTotal(long total) {
        this.total = total;
    }

    public int getStartIndex() {
        return startIndex;
    }

    public void setStartIndex(int startIndex) {
        this.startIndex = startIndex;
    }

    public T getSearchParam() {
        return searchParam;
    }

    public void setSearchParam(T searchParam) {
        this.searchParam = searchParam;
    }

    public List<T> getRecords() {
        return records;
    }

    public void setRecords(List<T> records) {
        this.records = records;
    }

    public int calStartIndex(){
        return currentPage == 1 ? 0 : (currentPage - 1) * pageSize;
    }

    @Override
    public String toString() {
        return "StandardPageData{" +
                "currentPage=" + currentPage +
                ", pageSize=" + pageSize +
                ", total=" + total +
                ", records=" + records +
                '}';
    }
}
